package com.java.base.exercise.designmode.builder;


import lombok.Data;

import java.io.Serializable;

/**
 * @Author RenPu
 * @Date 2021/6/30 12:10
 * @Version 1.0
 * @Description:
 **/

@Data
public class Person implements Serializable {

    private int id;
    private String name;
    private int age;
    private double weight;
    private int score;
    Locatio log;

    public Person() {
    }

    public Person(String name,int age) {
        this.name=name;
        this.age=age;
    }

    public static class PersonBuilder {
        Person person = new Person();

        public PersonBuilder baseInfo(int id, String name, int age) {
            person.id = id;
            person.name = name;
            person.age = age;
            return this;
        }

        public PersonBuilder weight(double weight) {
            person.weight = weight;
            return this;
        }


        public PersonBuilder score(int score) {
            person.score = score;
            return this;
        }

        public PersonBuilder loc(String street, String roomNo) {
            person.log = new Locatio(street, roomNo);
            return this;
        }

        public Person builder() {
            return person;
        }
    }


    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                ", score=" + score +
                ", log=" + log +
                '}';
    }
}

class Locatio {

    String street;
    String roomNo;

    public Locatio(String street, String roomNo) {
        this.street = street;
        this.roomNo = roomNo;
    }

    @Override
    public String toString() {
        return "Locatio{" +
                "street='" + street + '\'' +
                ", roomNo='" + roomNo + '\'' +
                '}';
    }
}
